<?php
/**
 * Created by PhpStorm.
 * User: 86182
 * Date: 2020/6/26
 * Time: 13:31
 */

namespace App\Serves;
use App\Models\Goods\Goods as GoodsModel;
use App\Models\Goods\Category as CategoryModel;
use App\Serves\CategoryServe;


use Illuminate\Http\Request;


class TestServe
{
    public static function getGoodsByCatid($catid){
        $goods = GoodsModel::getAllGoods($catid);
        $categorys = CategoryModel :: getAllCategory();
        $res = array_column($categorys, 'name', 'id');

        foreach ($goods as &$good){
            $good['catName'] = $res[$good['category_id']];
        }
        return $goods ?? [];
    }
}